function get_time_difference(earlierDate, laterDate) {
	var nTotalDiff = laterDate.getTime() - earlierDate.getTime();
	var oDiff = new Object();

	oDiff.days = Math.floor(nTotalDiff / 86400000);
	nTotalDiff -= oDiff.days * 86400000;

	oDiff.hours = Math.floor(nTotalDiff / 3600000);
	nTotalDiff -= oDiff.hours * 3600000;

	oDiff.minutes = Math.floor(nTotalDiff / 60000);
	nTotalDiff -= oDiff.minutes * 60000;

	oDiff.seconds = Math.floor(nTotalDiff / 1000);

	return oDiff;

}
jQuery(document).ready(
		function($) {
			function setTime() {
				var end_date = new Date($('#product-timer-end').val() * 1000);
				$('#product-timer-now').val(parseInt($('#product-timer-now').val())+1);
				var now = new Date($('#product-timer-now').val()* 1000);
				var diff = get_time_difference(now, end_date);
				if (diff.days >= 0 && diff.hours >= 0 && diff.minutes >= 0
						&& diff.seconds >= 0) {
					jQuery('#product-timer').html(
							diff.days + " day(s):" + diff.hours + " hour(s):"
									+ diff.minutes + " minute(s):"
									+ diff.seconds + " second(s)");
					setTimeout(setTime, 1000);
				}

			}
			if ($('#product-timer-end').length > 0) {
				var end_date = new Date($('#product-timer-end').val() * 1000);
				var now = new Date($('#product-timer-now').val()* 1000);
				var diff = get_time_difference(now, end_date);
				if (diff.days >= 0 && diff.hours >= 0 && diff.minutes >= 0
						&& diff.seconds >= 0) {
					setTime();
				}
			}
		});